home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 April / EnigmA AMIGA RUN 17 (1997)(G.R. Edizioni)(IT)[!][issue 1997-04][EAR-CD].iso / EARCD / text / hyper / hsc_source.lha / hsc / source / hsclib / attrib.h < prev    next >
C/C++ Source or Header  |  1996-09-12  |  5KB  |  138 lines

  1. /*
  2.  * hsclib/attribute.h
  3.  *
  4.  * attribute structure and funcs for hsc
  5.  */
  6.  
  7. #ifndef HSC_ATTRIBUTE_H
  8. #define HSC_ATTRIBUTE_H
  9.  
  10. /* variable types */
  11. #define VT_NONE   0             /* no type; only after init */
  12. #define VT_URI    1             /* uri */
  13. #define VT_STRING 2             /* text string */
  14. #define VT_BOOL   3             /* boolean */
  15. #define VT_NUM    4             /* TODO: numeric */
  16. #define VT_ENUM   5             /* enumerator */
  17. #define VT_ID     6             /* TODO: id (name reference) */
  18. #define VT_COLOR  7             /* TODO: jerk's color */
  19.  
  20. #define VT_STR_URI    "URI"     /* uri */
  21. #define VT_STR_STRING "STRING"  /* text string */
  22. #define VT_STR_BOOL   "BOOL"    /* boolean */
  23. #define VT_STR_NUM    "NUM"     /* numeric */
  24. #define VT_STR_ENUM   "ENUM"    /* enumerator */
  25. #define VT_STR_ID     "ID"      /* id (name reference) */
  26. #define VT_STR_COLOR  "COLOR"   /* color */
  27.  
  28. /* variable flags */
  29. #define VF_ONLYONCE     (1<<0)  /* attribute may occure only once */
  30. #define VF_REQUIRED     (1<<1)  /* attribute is required */
  31. #define VF_CONST        (1<<2)  /* attribute is read-only: <$DEFINE> */
  32. #define VF_JERK         (1<<3)  /* attribute only used by jerks */
  33. #define VF_STRIPEXT     (1<<4)  /* URI: strip tag, if external */
  34. #define VF_GETSIZE      (1<<5)  /* URI: get WIDTH & HEIGHT from here */
  35.  
  36. #define VF_KEEP_QUOTES  (1<<28) /* keep quotes untouched */
  37. #define VF_GLOBAL       (1<<29) /* attribute is global: <$DEFINE> */
  38. #define VF_MACRO        (1<<30) /* macro-attr */
  39. #define VF_TAG          (1<<31) /* tag-attr (see note below) */
  40.  
  41. /*
  42.  * NOTE on VF_TAG:
  43.  *
  44.  * Within uri-attributes, there is one problem: if you pass
  45.  * an uri-attr to a macro or <$define>, the uri is parsed twice,
  46.  * when attribute is passed to tag.
  47.  * This produces shit when the uri is parsed the second time
  48.  * (eg absolute uri is converted again)
  49.  *
  50.  * Therefor, uris are only parsed, if the VF_TAG-flag is
  51.  * enabled. By default, VF_TAG is disabled and can only be
  52.  * enabled when copying local macro attribute to the global
  53.  * attribute list. (see "copy_local_varlist()" in "attrib.c")
  54.  */
  55.  
  56. #define VF_CONST_STR    "CONST" /* attr is read only <$DEFINE> */
  57. #define VF_CONST_SHT    "C"
  58. #define VF_GLOBAL_STR   "GLOBAL"        /* global attribute <$DEFINE> */
  59. #define VF_GLOBAL_SHT   "G"
  60. #define VF_JERK_STR     "JERK"  /* attr only used by jerks */
  61. #define VF_JERK_SHT     "J"
  62. #define VF_ONLYONCE_STR "ONLYONCE"      /* attr may appear only once in tag */
  63. #define VF_ONLYONCE_SHT "1"
  64. #define VF_REQUIRED_STR "REQUIRED"      /* attr is required */
  65. #define VF_REQUIRED_SHT "R"
  66. #define VF_STRIPEXT_STR "STRIPEXT"      /* strip tag, if URI is external */
  67. #define VF_STRIPEXT_SHT "X"
  68. #define VF_GETSIZE_STR  "GETSIZE"       /* follow URI to get WIDTH & HEIGHT */
  69. #define VF_GETSIZE_SHT  "Z"
  70.  
  71. /* prefix for temporary attributes */
  72. #define PREFIX_HSCATTR "HSC."
  73. #define PREFIX_TMPATTR "HSC.TMP."
  74.  
  75. /* chars that act like opening/closing quote */
  76. #define VQ_STR_QUOTE "\"'"
  77.  
  78. /* "no quote" value for quote in HSCATTR */
  79. #define VQ_NO_QUOTE 0
  80.  
  81. /* error return value for set_macro_args() to set var->macro_id with */
  82. #define MCI_GLOBAL  0           /* indicate global attributes */
  83. #define MCI_ERROR   0xffffffff
  84. #define MCI_APPCTAG 0xfffffffe  /* used by app_ctag(); see "tag.c" */
  85.  
  86. /* attribute structure */
  87. typedef struct hscvar
  88. {
  89.     STRPTR name;                /* macro id */
  90.     STRPTR deftext;             /* deftext text */
  91.     STRPTR text;                /* text to be expanded to */
  92.     STRPTR enumstr;             /* enumerator string */
  93.     ULONG macro_id;             /* macro-call-id for local var */
  94.     ULONG varflag;              /* flags; see VF_xx */
  95.     int quote;                  /* quote char */
  96.     BYTE vartype;               /* type; see VT_xx */
  97. }
  98. HSCATTR;
  99.  
  100. #define HSCVAR HSCATTR          /* TODO: remove */
  101.  
  102. /*
  103.  * global funcs
  104.  */
  105. #ifndef NOEXTERN_HSCLIB_VARS_H
  106.  
  107. extern VOID prt_varlist(DLLIST * varlist, STRPTR title);
  108.  
  109. extern HSCATTR *new_hscattr(STRPTR newname);
  110. extern VOID del_hscattr(APTR data);
  111. extern HSCATTR *cpy_hscattr(HSCATTR * oldvar);
  112.  
  113. extern DLNODE *find_attrnode(DLLIST * varlist, STRPTR name);
  114. extern HSCATTR *find_varname(DLLIST * varlist, STRPTR name);
  115. extern HSCATTR *app_var(DLLIST * varlist, STRPTR newname);
  116.  
  117. extern BOOL check_enumstr(HSCATTR * var, STRPTR value, INFILE * inpf);
  118.  
  119. extern STRPTR set_vartext(HSCATTR * var, STRPTR newtext);
  120. extern BOOL set_varbool(HSCATTR * attr, BOOL value);
  121. extern BOOL clr_vartext(HSCATTR * var);
  122. extern VOID clr_attrdef(HSCATTR * attr);
  123. extern BOOL clr_varlist(DLLIST * varlist);
  124. extern VOID clr_varlist_bool(DLLIST * varlist);
  125.  
  126. extern STRPTR get_vartext_byname(DLLIST * varlist, STRPTR name);
  127. extern STRPTR get_vartext(HSCATTR * var);
  128. extern BOOL get_varbool_byname(DLLIST * varlist, STRPTR name);
  129. extern BOOL get_varbool(HSCATTR * attr);
  130. extern LONG get_varnum(HSCATTR * attr);
  131. extern LONG get_varnum_byname(DLLIST * varlist, STRPTR name);
  132.  
  133. extern STRPTR get_vardeftext(HSCATTR * var);
  134.  
  135. #endif /* NOEXTERN_HSCLIB_ATTRIBUTE_H */
  136. #endif /* HSCLIB_ATTRIBUTE_H */
  137.  
  138.